package com.itheima.controller.utils;

import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

//作为springmvc的异常处理器
//@ControllerAdvice
@RestControllerAdvice  //这个是@ControllerAdvice和@ResponseBody的整合
public class ProjectExceptionAdvice {
    //拦截所有的异常信息
    @ExceptionHandler(Exception.class)
    public Result doException(Exception ex){
        //记录日志

        //通知运维

        //通知开发
        ex.printStackTrace();
        //return new Result(false,"服务器故障，请稍后再试！");
        return new Result("服务器故障，请稍后再试！");

    }
}
